/**
 * 牌型定义
 */

export const enum LANDLORD_TYPE {
  SINGLE = 0,             // 单牌
  DRAGON,                 // 单顺子(5个及以上)

  PAIR,                   // 对牌
  MULIT_PAIRS,            // 双顺子(3个及以上)

  THREE,                  // 三张不带牌
  THREE_PLUS_ONE,         // 三带一
  THREE_PLUS_TWO,         // 三带二
  MULITY_THREE,           // 3顺子不带牌
  MULITY_THREE_PLUS_ONE,  // 3顺子带1个牌
  MULITY_THREE_PLUS_TWO,  // 3顺子带2个牌

  FOUR_PLUS_TWO,          // 四带2张
  FOUR_PLUS_FOUR,         // 四带2对
  MULITY_FOUR,            // 四顺子不带牌
  MULITY_FOUR_PLUS_TWO,   // 四顺子带2张
  MULITY_FOUR_PLUS_FOUR,  // 四顺子带4张

  COMMON_BOMB,            // 炸弹
  JOKER_BOMB              // 王炸
}

function GetPokerSetTypeName(pattern: number): string {
  switch (pattern) {
    case LANDLORD_TYPE.SINGLE: return "单牌";
    case LANDLORD_TYPE.DRAGON: return "单顺子";
    case LANDLORD_TYPE.PAIR: return "对牌";
    case LANDLORD_TYPE.MULIT_PAIRS: return "双顺子";
    case LANDLORD_TYPE.THREE: return "三张牌";
    case LANDLORD_TYPE.THREE_PLUS_ONE: return "三带一";
    case LANDLORD_TYPE.THREE_PLUS_TWO: return "三带二";
    case LANDLORD_TYPE.MULITY_THREE: return "三顺子不带牌";
    case LANDLORD_TYPE.MULITY_THREE_PLUS_ONE: return "三顺子带一张";
    case LANDLORD_TYPE.MULITY_THREE_PLUS_TWO: return "三顺子带两张";
    case LANDLORD_TYPE.FOUR_PLUS_TWO: return "四带二";
    case LANDLORD_TYPE.FOUR_PLUS_FOUR: return "四带四";
    case LANDLORD_TYPE.MULITY_FOUR: return "四顺子不带牌";
    case LANDLORD_TYPE.MULITY_FOUR_PLUS_TWO: return "四顺子带两张";
    case LANDLORD_TYPE.MULITY_FOUR_PLUS_FOUR: return "四顺子带四张";
    case LANDLORD_TYPE.COMMON_BOMB: return "炸弹";
    case LANDLORD_TYPE.JOKER_BOMB: return "火箭";
    default: return "未定义的牌型";
  }
}

//
export class SetInfo {
  public setType: number;
  public cardValueMinAndMax: Map<string, number>;

  constructor(setType: number, minValue: number, maxValue: number) {
    this.setType = setType;
    this.cardValueMinAndMax = new Map<string, number>([["min", minValue], ["max", maxValue]]);
  }

  public GetRangeWidth(): number {
    return this.cardValueMinAndMax.get("max")! - this.cardValueMinAndMax.get("min")! + 1;
  }

  public GetSetType(): number {
    return this.setType;
  }

  public GetSetTypeName(): string {
    return GetPokerSetTypeName(this.setType);
  }

  public GetMinValue(): number {
    return this.cardValueMinAndMax.get("min")!;
  }

  public GetMaxValue(): number {
    return this.cardValueMinAndMax.get("max")!;
  }
}
